package com.group4.admin.beans;

import com.group4.entity.Parent;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ActionEvent;

/**
 * controlles adminParent.xhtml
 * 
 * @author andake
 */
@ManagedBean
@RequestScoped
public class AdminParentsControllerBean {
    
    @ManagedProperty(value="#{adminParentsBackingBean}")
    AdminParentsBackingBean apb;

    /** Creates a new instance of AdminParentsControllerBean */
    public AdminParentsControllerBean() {
    }

    public AdminParentsBackingBean getApb() {
        return apb;
    }

    public void setApb(AdminParentsBackingBean apb) {
        this.apb = apb;
    }
    
    // listens for add parent event 
    public void addParentListener() {
        apb.addParent();
    }
    
    // listens for delete parent event
    public void deleteParentListener(ActionEvent e) {
        Parent p = (Parent) e.getComponent().getAttributes().get("parentobj");
        apb.deleteParent(p);
    }
}
